K8SPSMDB-1654: Add vector search support#2360
Conversation
7183630 to
f41e238
Compare
f41e238 to
bf080cd
Compare
51c6e61 to
8607ca8
Compare
| accessModes: | ||
| - ReadWriteOnce |
There was a problem hiding this comment.
I think it should be set by default in the CheckNSetDefaults the same way we do it for replsets
commit: 3171494 |
| // unmarshals into the existing struct in place, so only fields that | ||
| // appear in spec.Configuration are overridden — every other default | ||
| // is preserved. | ||
| func userMongotConfig(cr *api.PerconaServerMongoDB, rs *api.ReplsetSpec) (mongot.Config, error) { |
There was a problem hiding this comment.
| // SearchHost returns the fully qualified address mongod uses to reach | ||
| // this replset's mongot — | ||
| // `<cluster>-<rs>-search-0.<cluster>-<rs>-search.<ns>.<dnsSuffix>:27028`. | ||
| func SearchHost(cr *api.PerconaServerMongoDB, rs *api.ReplsetSpec) string { |
There was a problem hiding this comment.
It is called in the same package, do we need to export it?
| // containers are ready, AppStateStopping / AppStatePaused when the | ||
| // cluster is paused. NotFound on the StatefulSet (creation in flight) | ||
| // also returns AppStateInit. | ||
| func (r *ReconcilePerconaServerMongoDB) searchStatus(ctx context.Context, cr *api.PerconaServerMongoDB, rs *api.ReplsetSpec) (api.SearchStatus, error) { |
There was a problem hiding this comment.
Can we add a unit test for this using fake client?
| } | ||
| } | ||
|
|
||
| if cr.Spec.Search != nil && cr.Spec.Search.Enabled { |
There was a problem hiding this comment.
| if cr.Spec.Search != nil && cr.Spec.Search.Enabled { | |
| if cr.IsSearchEnabled() { |
| toDelete = append(toDelete, naming.ArbiterStatefulSetName(cluster, rs)) | ||
| } | ||
| if cluster.IsSearchEnabled() { | ||
| toDelete = append(toDelete, naming.SearchStatefulSetName(cluster, rs)) |
There was a problem hiding this comment.
does this work? I think we might be trying to delete one sts for configsvr replset too (which does not exist). We might need the rs.ClusterRole == api.ClusterRoleConfigSvr check here too
| annotations = map[string]string{} | ||
| } | ||
| if configHash != "" { | ||
| annotations["percona.com/configuration-hash"] = configHash |
There was a problem hiding this comment.
Does it need the ssl hashes too? Not sure how it picks up SSL cert changes
| } | ||
|
|
||
| if rs == nil || rs.Search == nil { | ||
| return cr.Spec.Search |
There was a problem hiding this comment.
Do we need to return DeepCopy() here as well? I think we might be updating a shared object on the caller side when no overrides are specified
| if err := r.client.Delete(ctx, sts); err != nil && !k8serrors.IsNotFound(err) { | ||
| return errors.Wrapf(err, "delete StatefulSet %s", sts.Name) | ||
| } | ||
| if err := r.client.Delete(ctx, svc); err != nil && !k8serrors.IsNotFound(err) { | ||
| return errors.Wrapf(err, "delete Service %s", svc.Name) | ||
| } | ||
| if err := r.client.Delete(ctx, cm); err != nil && !k8serrors.IsNotFound(err) { | ||
| return errors.Wrapf(err, "delete ConfigMap %s", cm.Name) | ||
| } |
| // StatefulSet returns the StatefulSet object that runs the mongot | ||
| // group for the given replset. configHash is set as a pod-template | ||
| // annotation so a ConfigMap content change rolls the pods. | ||
| func StatefulSet(cr *api.PerconaServerMongoDB, rs *api.ReplsetSpec, initImage, configHash string) *appsv1.StatefulSet { |
There was a problem hiding this comment.
A unit test for this would be nice as well
CHANGE DESCRIPTION
This PR is adding vector search (mongot) support into operator based on the proposal in #2332
I won't repeat the same things here that is already in the proposal. The following are the implementation details:
pkg/psmdb/vectorsearchpackage contains all code that builds StatefulSet, ConfigMap, Service for vector search.mongodandmongosrequires special configuration to communicate with mongot instances. We introduce two functionsInjectMongodConfigandInjectMongosConfigto inject required parameters intosetParametersection without overriding the custom configuration that users already have in their cr.yaml and creates necessary ConfigMap objects.mongotand stores in a ConfigMap. If user wants customizemongotoptions, they can put a partial configuration insearch.configurationand operator overrides only customized fields.mongod-datavolume by default. I decided to remove that mount for crVersion >1.23 because this volume is not used in init containers at all. This caused a lot of diffs in e2e test compare files.vector-searchandvector-search-sharded. This tests requireIMAGE_MONGODto point PSMDB v8.3 which we don't have images yet. In my testing I used a custom image:perconalab/percona-server-mongodb:8.3. For vector search, we also don't have images but upstream image works fine:mongodb/mongodb-community-search:latest. Note that once we have images provided by Percona, we might need to change the command we run to startmongot.vector-search-shardedtests logical backups/restores with vector search enabled. PBM has a bug that breaks sharded v8.3 clusters after logical restores. I decided to skip this test until it's resolved.CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability